package Java实训.第五天异常和IO流;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Scanner;

public class Num1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个文件路径:");
        File file = new File(sc.next());
        System.out.println("文件名为: " + file.getName());
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
        System.out.println(sdf.format(file.lastModified()));
        if (file.length()<1024*1024){
            System.out.println(file.length()/1024.0 + "KB");
        }
        else if(file.length()<1024*1024*1024){
            System.out.println(file.length()/1024/1024.0 + "MB");
        }
        else if(file.length()<1024*1024*1024*1024){
            System.out.println(file.length()/1024/1024/1024.0 + "GB");
        }
        else if(file.length()<1024*10241024*1024*1024){
            System.out.println(file.length()/1024/1024/1024/1024.0 + "TB");
        }
        else if(file.length()<1024*1024*1024*1024*1024*1024){
            System.out.println(file.length()/1024/1024/1024/1024/1024.0 + "PB");
        }
        else if(file.length()<(long) 1024*1024*1024*1024*1024*1024*1024){
            System.out.println(file.length()/1024/1024/1024/1024/1024/1024.0 + "EB");
        }
    }
}
